﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Globalization;

namespace Axe.ComponentModel
{
    public class DateFormatsConverter : StringConverter
    {
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }

        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return true;
        }

        public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            DateTimeFormatInfo d = CultureInfo.CurrentCulture.DateTimeFormat;

            List<string> items = new List<string>();
            items.Add(d.LongDatePattern);
            items.Add(d.MonthDayPattern);
            items.Add(d.ShortDatePattern);
            items.Add(d.YearMonthPattern);

            StandardValuesCollection coll = new StandardValuesCollection(items);

            return coll;
        }

        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            return DateTime.Now.ToString(value as string, culture);
        }
    }
}
